[Solved] Blur not working

您所在的位置:网站首页 solved page vs window in wpf 9to5answer [Solved] Blur not working

[Solved] Blur not working

2023-03-22 07:09| 来源: 网络整理| 查看: 265

Blur not working - Angular 2 angular blur 20,607 Solution 1

Your blur event is not working because your div can't receive focus in the first place. If you add tabindex="1" (1 can be replaced with any number) or contentEditable (this will make div's content editable) to your div, it will be able to receive focus and then blur event will work. Plus, you can then use focus instead of click.

Solution 2

You can also try (focusout)="unfocusAreaInput()" on your div. That will fire when any focusable element inside the div loses focus (incl. when the element is removed) and some other element in the div isn't simultaneously focused.

If you want to know what element lost focus inside your div, you can pass that in like so: (focusout)="unfocusAreaInput($event.target)".

More information here: https://developer.mozilla.org/en-US/docs/Web/API/Element/focusout_event

Solution 3

Use tabindex property with it. Setting

tabindex="0"

will give it highest priority in getting focus thus your blur event will work

Share: 20,607 BeniaminoBaggins Author by BeniaminoBaggins

I dabble in developing web and mobile apps.

Updated on July 05, 2022 Comments BeniaminoBaggins BeniaminoBaggins 6 months

I'm trying to set a blue event in angular 2 like so:

component.ts:

import { Component, ViewChild, ElementRef, Output, EventEmitter } from '@angular/core'; import { GoogleplaceDirective } from 'angular2-google-map-auto-complete/directives/googleplace.directive'; @Component({ selector: 'my-area', directives: [GoogleplaceDirective], templateUrl: 'app/find-page/area-picker.component.html', styleUrls: ['app/find-page/area-picker.component.css'] }) export class AreaComponent { public address: Object; @ViewChild('areaInput') areaInput; areaSelected: boolean = false; @Output() onAreaSelected = new EventEmitter(); @Output() onAreaDeselected = new EventEmitter(); constructor(el: ElementRef) { } getAddress(place: Object) { this.address = place['formatted_address']; var location = place['geometry']['location']; var lat = location.lat(); var lng = location.lng(); console.log("Address Object", place); } focusAreaInput() { this.areaInput.nativeElement.focus(); this.onAreaSelected.emit(true); } unfocusAreaInput() { this.onAreaSelected.emit(false); } }

unfocusAreaInput() never gets executed. Why?

Sunil Garg Sunil Garg over 2 years (blur) not working on div even after setting the tabindex=0 Sunil Garg Sunil Garg over 2 years not working, (blur) on div even after setting tabindex=0, the div also contains ngIf, is that matters? Funn_Bobby Funn_Bobby about 2 years This doesn't work...is there an updated answer? This shouldn't be marked as the answer unless a working example is shown. Emilia Heller-Mrotek Emilia Heller-Mrotek over 1 year That's not working because div is not focused when initialized anyway. I have added window.document.getElementById('container').focus() in my ngOnInit() and then it works. Needed to outline: 0 in css for div as well. Recents Why Is PNG file with Drop Shadow in Flutter Web App Grainy? How to troubleshoot crashes detected by Google Play Store for Flutter app Cupertino DateTime picker interfering with scroll behaviour Why does awk -F work for most letters, but not for the letter "t"? Flutter change focus color and icon color but not works How to print and connect to printer using flutter desktop via usb? Critical issues have been reported with the following SDK versions: com.google.android.gms:play-services-safetynet:17.0.0 Flutter Dart - get localized country name from country code navigatorState is null when using pushNamed Navigation onGenerateRoutes of GetMaterialPage Android Sdk manager not found- Flutter doctor error Flutter Laravel Push Notification without using any third party like(firebase,onesignal..etc) How to change the color of ElevatedButton when entering text in TextField


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3